import datetime

from django.db import models
from django.utils import timezone

class Product(models.Model):
	product_id=models.CharField(max_length=200)
	name=models.CharField(max_length=200)
	category=models.CharField(max_length=200)
	website=models.CharField(max_length=200)
	brand=models.CharField(max_length=200)
	sale_rank=models.IntegerField()
	avg_rating=models.DecimalField(max_digits=10, decimal_places=5)
	num_reviews=models.IntegerField()
	price=models.DecimalField(max_digits=15, decimal_places=2)
	tags=models.TextField()
	description=models.TextField()
	update_date=models.DateField(auto_now=False, auto_now_add=False)
	def __unicode__(self):
		return '%s (%s)' % (self.name, self.website)
		
	class Meta():
		db_table = 'product'

class Feature(models.Model):
	feature=models.CharField(max_length=200)
	frequency=models.IntegerField()
	category=models.CharField(max_length=200)
	def __unicode__(self):
		return self.feature
		
	class Meta():
		db_table = 'feature'

class Product_Score(models.Model):
	product_id=models.CharField(max_length=200)
	score=models.DecimalField(max_digits=10, decimal_places=7)
	update_date=models.DateField(auto_now=False, auto_now_add=False)
	category=models.CharField(max_length=200)
	
	class Meta():
		db_table = 'score_p'

class Feature_Score(models.Model):
	product_id=models.CharField(max_length=200)
	feature=models.CharField(max_length=200)
	score=models.DecimalField(max_digits=10, decimal_places=7)
	num_reviews=models.IntegerField()
	update_date=models.DateField(auto_now=False, auto_now_add=False)
	category=models.CharField(max_length=200)

	class Meta():
		db_table='score_pf'

class Average_Product_Score(models.Model):
	average_score=models.DecimalField(max_digits=10, decimal_places=7)
	category=models.CharField(max_length=200)
	
	class Meta():
		db_table='average_score_p'

class SD_Product_Score(models.Model):
	sd_score=models.DecimalField(max_digits=10, decimal_places=7)
	category=models.CharField(max_length=200)

	class Meta():
		db_table='sd_score_p'

class Average_Feature_Score(models.Model):	
	feature=models.CharField(max_length=200)	
	average_score=models.DecimalField(max_digits=10, decimal_places=7)
	category=models.CharField(max_length=200)

	class Meta():
		db_table='average_score_pf'

class SD_Feature_Score(models.Model):
	feature=models.CharField(max_length=200)	
	sd_score=models.DecimalField(max_digits=10, decimal_places=7)
	category=models.CharField(max_length=200)

	class Meta():
		db_table='sd_score_pf'

class Review(models.Model):
	review_id=models.CharField(max_length=200)
	product_id=models.CharField(max_length=200)
	helpful=models.CharField(max_length=255)
	star=models.IntegerField()
	title=models.CharField(max_length=200)
	content=models.TextField()
	tags=models.TextField()
	customer_name=models.CharField(max_length=200)
	customer_link=models.CharField(max_length=200)
	time=models.DateTimeField(auto_now=False, auto_now_add=False)

	class Meta():
		db_table='review'